import {getOne as one} from "@/api/business/medicine";

let showMainContent;
export default {
  editBtnText:"审核",
  columnBtn: false,
  menu:showMainContent,
  height:'auto',
  calcHeight: 30,
  tip: false,
  searchShow: true,
  searchMenuSpan: 6,
  border: true,
  index: true,
  viewBtn: false,
  selection: false,
  menuWidth: 300,
  column: [
    {
      label: "id",
      prop: "id",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "上报单ID",
      prop: "purchaseId",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "药品流水号",
      prop: "medicineNo",
      type: "input",
      search: false,
      editDisabled:false,
      editDisplay: false,
      hide: true,
      viewDisplay: false,
      change:({column,value})=>{
        console.log(value)
        // 调用后端接口查询药品信息
        one(value)
          .then(response => {
            const data = response.data.dataSub;
            // 填充其他对应字段
            this.optionSub.column.forEach(item => {
              this.form[item.prop] = data[item.prop]
            })
          })
          .catch(error => {
            console.error('Failed to fetch medicine data:', error);
            callback(new Error('暂未获取药品数据，请继续填报完毕，并等待审核！')); // 执行验证失败
          });
      },
      rules: [
        {
          required: true,
          message: "请输入药品流水号",
          trigger: "blur",
        }
      ]
    },
    {
      label: "上报月份",
      prop: "month",
      type: "month",
      viewDisabled: true,
      viewDisplay: false,
      search: false,
      rules: [{
        required: true,
        message: "请输入上报月份",
        trigger: "blur"
      }],
    },

    {
      label: "通用名",
      prop: "medicineName",
      type: "input",

    },
    {
      label: "挂网类型",
      prop: "publishType",
      type: "select",
      hide: true,
      viewDisplay: false,
      editDisplay: false,
      dicUrl: "/api/blade-system/dict/dictionary?code=hang_net_type",
      dataType: "string",
      props: {
        label: "dictValue",
        value: "dictKey"
      },
    },
    {
      label: "剂型",
      prop: "shotType",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "规格",
      prop: "specification",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "包装",
      prop: "package",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "质量类型",
      prop: "qualityType",
      type: "input",
      display: false,
      editDisplay: false,
      hide: true,
      viewDisplay: false,
    },

    {
      label: "新版基药属性",
      prop: "baseMedProp",
      type: "input",
      disabled: false,
      hide: true,
      viewDisplay: false,
      editDisplay: false,
      display: false,
    },
    {
      label: "生产企业注册号",
      prop: "produceCompanyNo",
      type: "input",
      display: false,
      hide: true,
      viewDisplay: false,
      editDisplay: false,
    },
    {
      label: "生产企业名称",
      prop: "produceCompanyName",
      type: "input",
      viewDisplay: false,
      hide: true,
      editDisplay: false,
    },
    {
      label: "价格",
      prop: "price",
      type: "input",
      viewDisplay: false,
      hide: true,
      editDisplay: false,
    },
    {
      label: "实际采购单价",
      prop: "actualPrice",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "采购数量",
      prop: "amount",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "是否履行备案手续",
      prop: "fileRecord",
      type: "input",
      viewDisplay: false,
      editDisplay: false,
      hide: true,
    },
    {
      label: "地市",
      prop: "city",
      type: "input",
    },
    {
      label: "区县",
      prop: "district",
      type: "select",
      viewDisplay: false,
      hide: true,
      dicUrl: "/api/blade-system/dict/dictionary?code=medpur_institution",
      dataType: "string",
      props: {
        label: "dictValue",
        value: "dictKey"
      },
    },
    {
      label: "状态",
      prop: "status",
      type: "select",
      editDisabled:false,
      editDisplay: false,
      viewDisplay:false,
      dicUrl: "/api/blade-system/dict/dictionary?code=procure_report",
      dataType: "string",
      props: {
        label: "dictValue",
        value: "dictKey"
      },
    },
    {
      label: "创建人",
      prop: "createUser",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "创建时间",
      prop: "createTime",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "更新人",
      prop: "updateUser",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "更新时间",
      prop: "updateTime",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "删除标识",
      prop: "isDeleted",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    },
    {
      label: "创建部门",
      prop: "createDept",
      type: "input",
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true,
    }
  ]
}
